package com.hqd.ch03.test.web.v38;


import com.hqd.ch03.v38.context.stereotype.Controller;
import com.hqd.ch03.v38.web.bind.annotation.RequestMapping;
import com.hqd.ch03.v38.web.ui.Model;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
public class HelloController {
    @RequestMapping("/hello")
    public String sayHello(HttpServletRequest req, HttpServletResponse resp, Model model) {
        String key = "message";
        String message = (String) req.getAttribute(key);
        if (message == null) {
            message = "";
            throw new RuntimeException("error");
        }
        model.addAttribute(key, message + " v38 HandleMapping!");
        return "hello";
    }
}
